package com.example.util;

import lombok.Data;

import java.io.Serializable;

/**
 * Created by 殇 on 2022/6/14.
 */

import lombok.Data;

import java.io.Serializable;
/*返回前端数据封闭类*/
@Data
public class R implements Serializable {
    private static final long serialversionUID = 1L;
    private int code;
    private String msg;
    private Object data;
    private Long count;//分页信息：总条数


    public R(){}

    public R(int code ){
        this.code = code;
    }

    private R(int code,String msg,Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    private R(int code,String msg,Object data,Long count) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.count = count;
    }

    //        类型查询分页
    public static R ok(String msg,Object data,Long count){
        return new R(Constants.OK_COOE,Constants.OK_MSG,data,count);
    }


    //        类型添加返回
    public static R ok(){
        return new R();
    }

    public static R no(){return  new R(1);}

    //        如果操作有误则返回错误数量
    public static R no(int res){
        return new R(res);
    }


    public static long getSerialversionUID() {
        return serialversionUID;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }
}
